
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%--使用taglib 引入标签库--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  <meta name="renderer" content="webkit">
  <title>班级列表</title>
  <link rel="stylesheet" href="<c:url value="/css/pintuer.css"/>">
  <link rel="stylesheet" href="<c:url value="/css/user.css"/>">
  <script src="<c:url value="/js/jquery.js"/>"></script>
  <script src="<c:url value="/js/pintuer.js"/>"></script>
</head>
<body>
<form method="post" action="" id="listform">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 请假信息列表</strong>
    </div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <li>搜索：</li>
        <li>
          <input type="text" placeholder="请输入搜索关键字" id="keywords" name="keywords" class="input"
                 style="width:250px; line-height:17px;display:inline-block"/>
          <a class="button border-main icon-search"
             onclick="location.href='?action=search&keywords=' + encodeURIComponent(document.getElementById('keywords').value)">搜索</a>
        </li>
      </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <th style="width: 100px">ID</th>
        <th>请假单号</th>
        <th>请假课程</th>
        <th>请假天数</th>
        <th>学号</th>
        <th>请假时间</th>
        <th>状态</th>
        <th>审核时间</th>
        <th>操作</th>
      </tr>
      <%--使用JSTL迭代标签输出用户信息(User)列表list--%>
      <c:forEach var="m" items="${list}" varStatus="i">
        <tr>
          <td width="100">${i.count}</td>
          <td>${m.leaveID}</td>
          <td>${m.courseID}</td>
          <td>${m.daynum}</td>
          <td>${m.stuNo}</td>
          <td>${m.applytime}</td>
          <td>
            <c:choose>
              <c:when test="${m.status == 0}">
                未审核
              </c:when>
              <c:when test="${m.status == 1}">
                同意
              </c:when>
              <c:when test="${m.status == 2}">
                不同意
              </c:when>
            </c:choose>
          </td>
          <td>${m.audittime}</td>
          <td>
            <div class="button-group">
              <a class="button button-big bg-main dialogs" data-toggle="click" data-target="#mydialog" data-mask="1" data-width="50%"
                 data-leaveid="${m.leaveID}"
                 data-courseid="${m.courseID}"
                 data-reason="${m.reason}"
                 data-daynum="${m.daynum}"
                 data-stuno="${m.stuNo}"
                 data-applytime="${m.applytime}"
                 data-opinion="${m.opinion}">
                <span class="icon-search"></span> 预览</a>
            </div>
          </td>
        </tr>
      </c:forEach>
    </table>
    <div class="pagelist"><a href="">上一页</a> <span class="current">1</span><a href="">2</a><a
            href="">3</a><a href="">下一页</a><a href="">尾页</a></div>
  </div>
</form>
<div id="mydialog">
  <div class="dialog">
    <div class="dialog-head">
      <span class="close rotate-hover"></span><strong>请假申请</strong>
    </div>
    <form method="post" class="form-x" action="?action=edit">
    <div class="dialog-body">
        <div class="form-group">
          <div class="label">
            <label>请假编号:</label>
          </div>
          <div class="field">
            <input type="text" class="input  w50" readonly="readonly" name="leaveID"/>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>课程编号:</label>
          </div>
          <div class="field">
            <input type="text" class="input  w50" readonly="readonly" name="courseID"/>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>请假事由:</label>
          </div>
          <div class="field">
            <input type="text" class="input  w100" readonly="readonly" name="reason"/>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>天数:</label>
          </div>
          <div class="field">
            <input type="text" class="input  w50" readonly="readonly" name="daynum"/>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>学号:</label>
          </div>
          <div class="field">
            <input type="text" class="input  w50" readonly="readonly" name="stuNo"/>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>请假时间:</label>
          </div>
          <div class="field">
            <input type="text" class="input w50" readonly="readonly" name="applytime"/>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>审核意见：</label>
          </div>
          <div class="field">
            <input type="text" class="input  w100" name="opinion" data-validate="required:请输入审核意见" />
            <div class="tips"></div>
          </div>
        </div>
    </div>
    <div class="dialog-foot">
      <button type="submit" class="button bg-red" name="status" value="2">
        不同意</button>
      <button type="submit" class="button bg-green" name="status" value="1">
        同意</button>
    </div>
    </form>
  </div>
</div>
<script type="text/javascript">
  window.onload = function () {
    // 使用 JSTL 判断并插入操作结果
    <c:if test="${operation == 'success'}">
    alert("操作成功！");
    </c:if>
    <c:if test="${operation == 'failure'}">
    alert("操作失败，错误信息：${message}");
    </c:if>
  };
  $(document).ready(function () {
    // 监听预览按钮的点击事件
    $('.dialogs').click(function () {
      // 使用 jQuery 的 data() 方法获取自定义属性的值
      var leaveID = $(this).data('leaveid');
      var courseID = $(this).data('courseid');
      var reason = $(this).data('reason');
      var daynum = $(this).data('daynum');
      var stuNo = $(this).data('stuno');
      var applytime = $(this).data('applytime');
      var opinion = $(this).data('opinion')

      // 将值填充到弹窗的对应位置
      $('input[name="leaveID"]').val(leaveID);
      $('input[name="courseID"]').val(courseID);
      $('input[name="reason"]').val(reason);
      $('input[name="daynum"]').val(daynum);
      $('input[name="stuNo"]').val(stuNo);
      $('input[name="applytime"]').val(applytime);
      $('input[name="opinion"]').val(opinion);
    })
  })
</script>
</body>
</html>
